/*
 * 文件名：ConfigManager.java	 
 * 时     间：上午9:56:27
 * 作     者：binghen       
 * 版     权： 2012-2022 湖南智软网络科技, 公司保留所有权利.
 * 联     系：http://www.073586.com/
 */
package com.local.manager.cfgManager;

import com.cz073586.tools.util.ResourceUtil;
import com.cz073586.tools.util.Tools;
import com.local.common.ExchangeConstan;

/**
 * 类描述:配置文件管理器
 * 
 * @ClassName: ConfigManager
 * @author binghen
 * @date 2015年4月2日 上午9:56:27
 */
public class ConfigManager
{
	private static ConfigManager instance;
	private String protocol;
	private String host;
	private String prot;// 端口号
	private String registerURI;
	private String whenIssuedIsSucceedUri;
	
	// 软路由编号
	private String exchangeNo;
	// 是否为调试模式，false标示需要往平台发送请求
	private boolean isDebug = false;
	
	private String carInUri;
	private String carOutUri;
	private String updateCarBillUri;
	private String addParkwellMemberUri;
	private String addPayBillUri;
	private String parkUuid;
	private String ftpPath;
	private String ftpHost;
	private String ftpPort;
	private String ftpAccount;
	private String ftpPwd;
	
	private String defaultCarType;
	private String screenMsg;
	private String screenMsgPay;
	private String screenMsgNoPay;
	private String screenMsgAutoPay;
	private String screenMsgBye;
	private boolean lockFlag = false;
	private boolean cloudPay = false;
	
	private boolean freeAutoOpen = false;
	
	private ConfigManager()
	{
		this.protocol = ResourceUtil.getValueByKey(ExchangeConstan.CFG_PATH,
				"protocol");
		this.host = ResourceUtil
				.getValueByKey(ExchangeConstan.CFG_PATH, "host");
		
		this.prot = ResourceUtil.getValueByKey(ExchangeConstan.CFG_PATH,
				"server_port");
		this.registerURI = ResourceUtil.getValueByKey(ExchangeConstan.CFG_PATH,
				"registerURI");
		this.exchangeNo = ResourceUtil.getValueByKey(ExchangeConstan.CFG_PATH,
				"exchange_id");
		String isDebug = ResourceUtil.getValueByKey(ExchangeConstan.CFG_PATH,
				"is_debug");
		if (!Tools.isEmpty(isDebug) && isDebug.trim().equalsIgnoreCase("true"))
		{
			this.isDebug = true;
		}
		this.carInUri = ResourceUtil.getValueByKey(ExchangeConstan.CFG_PATH,
				"carInUri");
		this.addParkwellMemberUri = ResourceUtil.getValueByKey(
				ExchangeConstan.CFG_PATH, "addParkwellMember");
		this.carOutUri = ResourceUtil.getValueByKey(ExchangeConstan.CFG_PATH,
				"carOutUri");
		this.updateCarBillUri = ResourceUtil.getValueByKey(
				ExchangeConstan.CFG_PATH, "updateCarBillUri");
		this.addPayBillUri = ResourceUtil.getValueByKey(
				ExchangeConstan.CFG_PATH, "payBillUri");
		this.whenIssuedIsSucceedUri = ResourceUtil.getValueByKey(
				ExchangeConstan.CFG_PATH, "whenIssuedIsSucceedUri");
		this.parkUuid = ResourceUtil.getValueByKey(ExchangeConstan.CFG_PATH,
				"parkUuid");
		this.defaultCarType = ResourceUtil.getValueByKey(ExchangeConstan.CFG_PATH,
				"default_car_type");
		this.screenMsg = ResourceUtil.getValueByKey(ExchangeConstan.CFG_PATH,
				"screen_msg");
		this.screenMsgPay = ResourceUtil.getValueByKey(ExchangeConstan.CFG_PATH,
				"screen_msg_pay");
		this.screenMsgNoPay = ResourceUtil.getValueByKey(ExchangeConstan.CFG_PATH,
						"screen_msg_no_pay");
		this.screenMsgAutoPay = ResourceUtil.getValueByKey(ExchangeConstan.CFG_PATH,
				"screen_msg_auto_pay");
		this.screenMsgBye = ResourceUtil.getValueByKey(ExchangeConstan.CFG_PATH,
				"screen_msg_bye");
		String lock = ResourceUtil.getValueByKey(ExchangeConstan.CFG_PATH,
				"lock_flag");
		if (!Tools.isEmpty(lock) && lock.trim().equalsIgnoreCase("true"))
		{
			this.lockFlag = true;
		}
		String cloud = ResourceUtil.getValueByKey(ExchangeConstan.CFG_PATH,
				"cloud_pay");
		if (!Tools.isEmpty(cloud) && cloud.trim().equalsIgnoreCase("true"))
		{
			this.cloudPay = true;
		}
		this.ftpPath = ResourceUtil.getValueByKey(ExchangeConstan.CFG_PATH,
				"ftp_path");
		this.ftpHost = ResourceUtil.getValueByKey(ExchangeConstan.CFG_PATH,
				"ftp_host");
		this.ftpPort = ResourceUtil.getValueByKey(ExchangeConstan.CFG_PATH,
				"ftp_port");
		this.ftpAccount = ResourceUtil.getValueByKey(ExchangeConstan.CFG_PATH,
				"ftp_account");
		this.ftpPwd = ResourceUtil.getValueByKey(ExchangeConstan.CFG_PATH,
				"ftp_pwd");
		String freeAuto = ResourceUtil.getValueByKey(ExchangeConstan.CFG_PATH,
				"free_auto_open");
		if (!Tools.isEmpty(freeAuto) && freeAuto.trim().equalsIgnoreCase("true"))
		{
			this.freeAutoOpen = true;
		}
	}
	
	public static ConfigManager instance()
	{
		if (null == instance)
		{
			instance = new ConfigManager();
		}
		
		return instance;
	}
	
	public String getFullRegisterUrl()
	{
		return this.protocol + "://" + this.host + ":" + this.prot
				+ this.registerURI;
	}
	
	public String getProtocol()
	{
		return protocol;
	}
	
	public String getHost()
	{
		return host;
	}
	
	public String getRegisterURI()
	{
		return registerURI;
	}
	
	public String getExchangeNo()
	{
		return exchangeNo;
	}
	
	public boolean isDebug()
	{
		return isDebug;
	}
	
	public String getCarInUri()
	{
		return this.protocol + "://" + this.host + ":" + this.prot + carInUri;
	}
	
	public String getCarOutUri()
	{
		return this.protocol + "://" + this.host + ":" + this.prot + carOutUri;
	}
	
	public String getUpdateCarBillUri()
	{
		return this.protocol + "://" + this.host + ":" + this.prot
				+ updateCarBillUri;
	}
	
	public String getAddParkwellMemberUri()
	{
		return this.protocol + "://" + this.host + ":" + this.prot
				+ addParkwellMemberUri;
	}
	
	public String getAddPayBillUri()
	{
		return this.protocol + "://" + this.host + ":" + this.prot
				+ addPayBillUri;
	}
	
	public String getParkName()
	{
		return parkUuid;
	}
	
	public String getProt()
	{
		return prot;
	}
	
	public String getWhenIssuedIsSucceedUri()
	{
		return this.protocol + "://" + this.host + ":" + this.prot
				+ whenIssuedIsSucceedUri;
	}

	public String getDefaultCarType() {
		return defaultCarType;
	}

	public void setDefaultCarType(String defaultCarType) {
		this.defaultCarType = defaultCarType;
	}

	public String getScreenMsg() {
		return screenMsg;
	}

	public void setScreenMsg(String screenMsg) {
		this.screenMsg = screenMsg;
	}

	public String getScreenMsgPay() {
		return screenMsgPay;
	}

	public void setScreenMsgPay(String screenMsgPay) {
		this.screenMsgPay = screenMsgPay;
	}

	public String getScreenMsgNoPay() {
		return screenMsgNoPay;
	}

	public void setScreenMsgNoPay(String screenMsgNoPay) {
		this.screenMsgNoPay = screenMsgNoPay;
	}

	public String getScreenMsgAutoPay() {
		return screenMsgAutoPay;
	}

	public void setScreenMsgAutoPay(String screenMsgAutoPay) {
		this.screenMsgAutoPay = screenMsgAutoPay;
	}

	public String getScreenMsgBye() {
		return screenMsgBye;
	}

	public void setScreenMsgBye(String screenMsgBye) {
		this.screenMsgBye = screenMsgBye;
	}

	public boolean isLockFlag() {
		return lockFlag;
	}

	public void setLockFlag(boolean lockFlag) {
		this.lockFlag = lockFlag;
	}

	public boolean isCloudPay() {
		return cloudPay;
	}

	public void setCloudPay(boolean cloudPay) {
		this.cloudPay = cloudPay;
	}

	public String getFtpPath()
	{
		return ftpPath;
	}

	public void setFtpPath(String ftpPath)
	{
		this.ftpPath = ftpPath;
	}

	public String getFtpHost()
	{
		return ftpHost;
	}

	public void setFtpHost(String ftpHost)
	{
		this.ftpHost = ftpHost;
	}

	public String getFtpPort()
	{
		return ftpPort;
	}

	public void setFtpPort(String ftpPort)
	{
		this.ftpPort = ftpPort;
	}

	public String getFtpAccount()
	{
		return ftpAccount;
	}

	public void setFtpAccount(String ftpAccount)
	{
		this.ftpAccount = ftpAccount;
	}

	public String getFtpPwd()
	{
		return ftpPwd;
	}

	public void setFtpPwd(String ftpPwd)
	{
		this.ftpPwd = ftpPwd;
	}

	public boolean isFreeAutoOpen()
	{
		return freeAutoOpen;
	}

	public void setFreeAutoOpen(boolean freeAutoOpen)
	{
		this.freeAutoOpen = freeAutoOpen;
	}
	
	
}
